define(['app'], function(app) {
	'use strict';

	//实例化方法
	var factory = function(Http) {
		function get_data_agentad(result) {
			if(false) {
				result = '{"success": true,"msg": "",' +
					'"result": {"store_id": "001"},' +
					'"session": "7311da98bd0f18eb15a96bcb263f4153"}';
				return JSON.parse(result);
			} else {
				return result;
			}
		}
		//可选品牌
		function get_brand_list(result) {
			if(false) {
				result = '{"success":true,"msg":"","result":{"brand":[{"id":"001","name":"世达"},{"id":"002","name":"博士"}]},"session":"7311da98bd0f18eb15a96bcb263f4153"}';
				return JSON.parse(result);
			} else {
				return result;
			}
		}

		//返回信息
		return {
			//添加代理商
			agent_add: function(params, callback) {
				Http.post({
					method: 'member.agenter.edit',
					updateParams: params
				},
				function(result) {
					//请求成功
					if(callback)
						callback(get_data_agentad(result));
				},
				function(e) {
					//请求异常
				},
				function() {
					//请求完成，一般不做什么事情
				});
			},
			agenter_list: function(key,nPage,callback,calldone) {
				Http.post({
					method: 'member.otheragenter.getlist',
					pagelimit: 30,
					nPage: nPage,
					key:key
				}, function(result) {
					if(callback)
						callback(result.result);
				},function(){
					
				},function(){
					if(calldone)
						calldone();
				})
			},
			agenter_detail:function(store_id,callback){
				Http.post({
					method:'member.agenter.detail',
					store_id:store_id
				},function(result){
					if(callback)
					callback(result.result);
				})
			},
			//一级、二级、三级分类一览
			getCatList: function(cat_id,brand_id,store_id,callback) {
				Http.post({
					method: 'brand.info.getNextCatLvl',
					cat_id:cat_id,
					brand_id:brand_id,
					store_id:store_id
				},
				function(result) {
					if(callback)
						callback(result);
				},
				function(e) {
					//请求异常
				},
				function() {
					//请求完成，一般不做什么事情
				});
			},

		};
	}

	factory.$inject = ['Http'];
	return app.registerService("Myagent_add", factory);
});